// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
// 配置axios 并且挂载到原型身上
import Axios from 'axios'
Vue.prototype.$axios=Axios
//引入swiper
import VueAwesomeSwiper from 'vue-awesome-swiper'
// require styles
import 'swiper/dist/css/swiper.css'
Vue.use(VueAwesomeSwiper, /* { default global options } */)
Vue.config.productionTip = false
//引入vuex
import store from './store'
//全局配置axios
Axios.defaults.baseURL = 'http://www.wwtliu.com';
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
//请求拦截
//添加请求拦截器
Axios.interceptors.request.use(function(config){
  //如果后期加上登陆注册 会用到post 
  if(config.method == "post"){
    config.data=qs.stringify(config.data)
  }
  console.log("请求"+config);
  //在发送请求之前做些什么
  return config;
},function(error){
  return Promise.reject(error);
});
//添加响应式拦截器
Axios.interceptors.response.use(function(response){
  console.log("相应"+response);
  //对相应数据做点啥
  return response;
},function(error){
  return Promise.reject(error);
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
